import { request } from '@inbiz/utils';
const version = InbizConfig.API_VERSION

export type IModelList = {
  Name: string;
  ID: string;
  Relations?: {
    ta: string;
    tid: string;
  }[];
}[];

// 查询数据列表
export async function getStaticDataList({
  appId,
  groupId,
}: {
  appId: string;
  groupId: string;
}): Promise<
  {
    Text: string;
    Value: string;
    Id: string;
    Key: string;
  }[]
> {
  return await request.get(
    `/inbiz/api/services/modelengine/v${version}/dictData?appId=${appId}&groupId=${groupId}`,
  );
}
// 保存数据列表
export async function saveStaticDataList(params: object): Promise<string> {
  return await request.post(`/inbiz/api/services/modelengine/v${version}/dictData`, {
    data: params,
  });
}
// 删除静态数据源分组
export async function delStaticDataList({
  appId,
  groupId,
}: {
  appId: string;
  groupId: string;
}): Promise<string> {
  return await request.delete(
    `/inbiz/api/services/modelengine/v${version}/dictGroup/${groupId}?appId=${appId}`,
  );
}
// 修改静态数据源分组
export async function putStaticDataList(appId: string, params: object): Promise<string> {
  return await request.put(`/inbiz/api/services/modelengine/v${version}/dictGroup?appId=${appId}`, {
    data: params,
  });
}
// 查询分组列表
export async function getStaticGroupList(appId: string): Promise<
  {
    Name: string;
    Id: string;
    Key: string;
  }[]
> {
  return await request.get(`/inbiz/api/services/modelengine/v${version}/dictGroup?appId=${appId}`);
}
// 保存分组列表
export async function saveStaticGroupList(params: object): Promise<string> {
  return await request.post(`/inbiz/api/services/modelengine/v${version}/dictGroup`, {
    data: params,
  });
}
// 修改分组列表
export async function editStaticGroupList(params: object): Promise<string> {
  return await request.put(`/inbiz/api/services/modelengine/v${version}/dictGroup`, {
    data: params,
  });
}
// 批量查询数据列表
export async function getListGroupIds({
  appId,
  groupIds,
}: {
  appId: string;
  groupIds: string;
}): Promise<object[]> {
  return await request.get(
    `/inbiz/api/services/front/modelengine/v${version}/dictData/groupIds/${appId}`,
    {
      params: { groupKeys: groupIds },
    },
  );
}

// 删除分组
// export async function deleteStaticGroupList(params: object): Promise<string> {
//   return await request.delete(`/inbiz/api/services/modelengine/v${version}/dictGroup` + params.id, {
//     data: params,
//   });
// }
